package callback;

/***
 * @author Ragnvald Fuglestein
 */

import java.util.ArrayList;
import java.util.HashMap;

public class Callback {
	
	private static HashMap<String, ArrayList<TrackListChangedInterface>> tracklistchangedcallbacks = new HashMap<String, ArrayList<TrackListChangedInterface>>();
	public static void registerTrackListChanged(String name, TrackListChangedInterface callback) {
		ArrayList<TrackListChangedInterface> l;
		if (tracklistchangedcallbacks.containsKey(name)) {
			l = tracklistchangedcallbacks.get(name);
		} else {
			l = new ArrayList<>();
			tracklistchangedcallbacks.put(name, l);
		}
		l.add(callback);
	}
	public static void tracklistChanged(String name) {
		if (tracklistchangedcallbacks.containsKey(name)) {
			for (TrackListChangedInterface m : tracklistchangedcallbacks.get(name)) {
				m.tracklistChanged();
			}
		}
	}

}
